package com.example.dockerdemo.bean;

import lombok.Data;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @PACKAGE_NAME: com.example.dockerdemo.bean
 * @NAME: LifeBean
 * @description: bean的生命周期
 * @DATE: 2024/4/2
 * @USER: fz
 **/
@Component
@Data
public class LifeBean implements BeanNameAware, BeanFactoryAware, ApplicationContextAware{
    String name;
    BeanFactory beanFactory;
    ApplicationContext applicationContext;

    String cifNo = "123456";

    @Override
    public void setBeanName(String s) {
        System.out.println("这是beanName=====" + s + "====");
        this.name = s;
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("这是beanFactory====" + beanFactory + "====");
        this.beanFactory = beanFactory;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("这是applicationContext===" + applicationContext + "====");
        this.applicationContext = applicationContext;
    }

    @PostConstruct
    public void init() {
        System.out.println("这是init====");
    }


}
